package com.csweimei.rentmanagementtreasure.tenant.ui.act.mine;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProviders;

import android.os.Bundle;
import android.widget.RadioGroup;

import com.chad.library.BR;
import com.csweimei.rentmanagementtreasure.R;
import com.csweimei.rentmanagementtreasure.base.AppViewModelFactory;
import com.csweimei.rentmanagementtreasure.databinding.ActivityPersonInfoBinding;
import com.csweimei.rentmanagementtreasure.tenant.viewModel.PersonInfoVM;

import me.goldze.mvvmhabit.base.BaseActivity;

public class PersonInfoActivity extends BaseActivity<ActivityPersonInfoBinding, PersonInfoVM> {


    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_person_info;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        viewModel.setActivity(this);
        binding.rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.rb_1){
                    viewModel.sex.set("男");
                }
                if (checkedId == R.id.rb_2){
                    viewModel.sex.set("女");
                }
            }
        });
    }

    @Override
    public PersonInfoVM initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this,factory).get(PersonInfoVM.class);
    }
}